Ext.define('AM.view.ZhuYuanView', {
		extend: 'Ext.grid.Panel',
		alias : 'widget.zhuYuanView',
		//store : 'ZhuYuanEmployeesStore',
		store : 'ZhuYuanEmployeesStore',
		border:false,
		columnLines:true,
//		selModel : Ext.create('Ext.selection.CheckboxModel'), 
		selModel: {
	        injectCheckbox: 0,
	        mode: "SIMPLE"     //"SINGLE"/"SIMPLE"/"MULTI"
//	        checkOnly: true     //只能通过checkbox选择
   		 },
   		selType: "checkboxmodel",
    	dockedItems: [{
        xtype: 'pagingtoolbar',
        dock: 'bottom',
        store : 'ZhuYuanEmployeesStore',
        displayInfo: true
    }],
		columns: [	
			        {text: 'ID', dataIndex: 'id',width:0,align:'center'},
			        {text: '序号',  xtype: 'rownumberer',width:50,align:'center',tdCls:'background-color: #8EE5EE;'},
			        { text: '姓名',  dataIndex: 'name',  width:80,align:'center'},
			        { text: '科室',dataIndex: 'dept', width:120,align:'center'},
			        { text: '所属组',  dataIndex: 'zuname',  width:80,align:'center'},
			        { text: '操作', dataIndex: 'id',width:80,align:'center',renderer : function(data, cell, record, rowIndex,columnIndex){
			        	    var resultStr = "<div class='controlBtn'>" +     
                            "<a href='javascript:void("+record.get('id')+");'class='alarm_detail'onclick='addZhu("+record.get('id')+")'>编组</a>&nbsp;&nbsp;&nbsp;&nbsp;"   
                            "</div>";     
         					 return resultStr;  
			       		  }
         	    	}
			     ],
			   tbar: [{
					     xtype : "combobox",
					     allowBlank:false,
					     labelAlign :"right",
						 fieldLabel: '选择科室',
						 id:"search_zhuyuandepartment1",
						 store :Ext.create('AM.store.TargetzhuyuanDepartStore'),
						 displayField: 'name',
						 valueField: 'id',
					     width:300
					  },
					  { xtype: 'button', text: '查询',handler: searchemp,icon : 'Ext/restful/images/find.png'
					  }
					]
})
function searchemp() {
		   var grid=this.ownerCt.ownerCt;
			var depart= Ext.getCmp('search_zhuyuandepartment1').getValue();
	       //此处为加载条件
		  grid.getStore().on('beforeload', function (store, options) {
		              var new_params = {serchdepartment:depart}
		                Ext.apply(store.proxy.extraParams, new_params);
		       });
	
		grid.getStore().reload();
					
}
function addZhu(id) {
	//alert('hiiiii');
	  var grid=Ext.create('AM.view.ZhuYuanView');
		var empID=id;
		 var myform1= new Ext.form.Panel({
		 			bodyPadding: 25,
			        labelWidth : 65,
					   items: [
			        {   
					     xtype : "combobox",
					     //allowBlank:true,
					     labelAlign :"right",
						 fieldLabel: '所属组',
						 name:'zu',
						 store :Ext.create('AM.store.SearchzuStore').load({params:{deptId:empID}}),
						 displayField: 'name',
						 valueField: 'id'
					    // width:220
							}

							]		        	
				        	       

		 })
			var win = new Ext.Window({
				title : "人员编组",
				width : 400,
				height : 200,
				frame:true,
				layout:'fit',
				items : [ myform1
							],
				buttons : [{
							text : "确定",
							handler : function() {
								win.getComponent(0).getForm().submit({
											 url : 'employees_addzu',
											 params :{ empID:empID},
											 success : function() {
											 	grid.getStore().reload();
												Ext.Msg.alert('提示', '编组成功');
												win.close();
											},
											failure : function() {
												Ext.Msg.alert('错误', '编组失败');
											},
											waitMsg : "请稍后，正在保存。。。。"
	
										});
							}
						}, {
							text : "重置",
							handler : function() {
								win.getComponent(0).getForm().reset();
							}
						}, {
							text : "取消",
							handler : function() {
												win.close();
											
							}
						}]
			});
		win.show();
}

